home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / Xsun / sun.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-09  |  8.7 KB  |  254 lines

  1. /*-
  2.  * sun.h --
  3.  *    Internal declarations for the sun ddx interface
  4.  *
  5.  * Copyright (c) 1987 by the Regents of the University of California
  6.  *
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * "$XConsortium: sun.h,v 5.7 89/12/06 09:37:35 rws Exp $ SPRITE (Berkeley)"
  16.  * $Header: /X11/R4/src/cmds/X/ddx/Xsun/RCS/sun.h,v 1.5 91/01/09 11:52:30 kupfer Exp $
  17.  */
  18. #ifndef _SUN_H_
  19. #define _SUN_H_
  20.  
  21. #define Time      SpriteTime
  22.  
  23. /* 
  24.  * Force spriteTime.h to be included here, so that its Time typedef 
  25.  * gets the correct name.
  26.  */
  27. #include    <sprite.h>
  28. #include    <spriteTime.h>
  29. #include    <kernel/devVid.h>
  30. #include    <dev/mouse.h>
  31. #include    <vm.h>
  32.  
  33. #include "sys/fb.h"
  34.  
  35.  
  36. #undef Time
  37.  
  38. #include    "X.h"
  39. #include    "Xproto.h"
  40. #include    "scrnintstr.h"
  41. #include    "screenint.h"
  42. #ifdef NEED_EVENTS
  43. #include    "inputstr.h"
  44. #endif NEED_EVENTS
  45. #include    "input.h"
  46. #include    "cursorstr.h"
  47. #include    "cursor.h"
  48. #include    "pixmapstr.h"
  49. #include    "pixmap.h"
  50. #include    "windowstr.h"
  51. #include    "gc.h"
  52. #include    "gcstruct.h"
  53. #include    "regionstr.h"
  54. #include    "colormap.h"
  55. #include    "miscstruct.h"
  56. #include    "dix.h"
  57. #include    "mfb.h"
  58. #include    "mi.h"
  59.  
  60. /*
  61.  * MAXEVENTS is the maximum number of events the mouse and keyboard functions
  62.  * will read on a given call to their GetEvents vectors.
  63.  */
  64. #define MAXEVENTS     32
  65.  
  66. /*
  67.  * Data private to any sun keyboard.
  68.  *    GetEvents reads any events which are available for the keyboard
  69.  *    ProcessEvent processes a single event and gives it to DIX
  70.  *    DoneEvents is called when done handling a string of keyboard
  71.  *        events or done handling all events.
  72.  *    devPrivate is private to the specific keyboard.
  73.  *    map_q is TRUE if the event queue for the keyboard is memory mapped.
  74.  */
  75. typedef struct kbPrivate {
  76.     int              type;               /* Type of keyboard */
  77.     int              fd;                    /* Descriptor open to device */
  78.     Mouse_Event      *(*GetEvents)();      /* Function to read events */
  79.     void          (*ProcessEvent)();    /* Function to process an event */
  80.     void          (*DoneEvents)();      /* Function called when all events */
  81.                     /* have been handled. */
  82.     pointer       devPrivate;            /* Private to keyboard device */
  83.     int          offset;        /* to be added to device keycodes */
  84.     KeybdCtrl      *ctrl;                /* Current control structure (for
  85.                       * keyclick, bell duration, auto-
  86.                       * repeat, etc.) */
  87. } KbPrivRec, *KbPrivPtr;
  88.  
  89. /*
  90.  * Data private to any sun pointer device.
  91.  *    GetEvents, ProcessEvent and DoneEvents have uses similar to the
  92.  *        keyboard fields of the same name.
  93.  *    pScreen is the screen the pointer is on (only valid if it is the
  94.  *        main pointer device).
  95.  *    dx and dy are relative coordinates on that screen (they may be negative)
  96.  */
  97. typedef struct ptrPrivate {
  98.     int              fd;                    /* Descriptor to device */
  99.     Mouse_Event       *(*GetEvents)();     /* Function to read events */
  100.     void          (*ProcessEvent)();    /* Function to process an event */
  101.     void          (*DoneEvents)();      /* When all the events have been */
  102.                     /* handled, this function will be */
  103.                     /* called. */
  104.     short         dx,                    /* Current X coordinate of pointer */
  105.           dy;                    /* Current Y coordinate */
  106.     pointer          devPrivate;            /* Field private to device */
  107. } PtrPrivRec, *PtrPrivPtr;
  108.  
  109. /*
  110.  * Cursor-private data
  111.  *    screenBits    saves the contents of the screen before the cursor
  112.  *                  was placed in the frame buffer.
  113.  *    source          a bitmap for placing the foreground pixels down
  114.  *    srcGC          a GC for placing the foreground pixels down.
  115.  *                  Prevalidated for the cursor's screen.
  116.  *    invSource     a bitmap for placing the background pixels down.
  117.  *    invSrcGC      a GC for placing the background pixels down.
  118.  *                  Also prevalidated for the cursor's screen Pixmap.
  119.  *    temp          a temporary pixmap for low-flicker cursor motion --
  120.  *                  exists to avoid the overhead of creating a pixmap
  121.  *                  whenever the cursor must be moved.
  122.  *    fg, bg          foreground and background pixels. For a color display,
  123.  *                  these are allocated once and the rgb values changed
  124.  *                  when the cursor is recolored.
  125.  *    scrX, scrY    the coordinate on the screen of the upper-left corner
  126.  *                  of screenBits.
  127.  *    state          one of CR_IN, CR_OUT and CR_XING to track whether the
  128.  *                  cursor is in or out of the frame buffer or is in the
  129.  *                  process of going from one state to the other.
  130.  */
  131. typedef enum {
  132.     CR_IN,        /* Cursor in frame buffer */
  133.     CR_OUT,        /* Cursor out of frame buffer */
  134.     CR_XING          /* Cursor in flux */
  135. } CrState;
  136.  
  137. typedef struct crPrivate {
  138.     PixmapPtr              screenBits; /* Screen before cursor put down */
  139.     PixmapPtr              source;     /* Cursor source (foreground bits) */
  140.     GCPtr             srcGC;        /* Foreground GC */
  141.     PixmapPtr              invSource;  /* Cursor source inverted (background) */
  142.     GCPtr             invSrcGC;   /* Background GC */
  143.     PixmapPtr              temp;        /* Temporary pixmap for merging screenBits
  144.                      * and the sources. Saves creation time */
  145.     Pixel             fg;         /* Foreground color */
  146.     Pixel             bg;         /* Background color */
  147.     int                  scrX,        /* Screen X coordinate of screenBits */
  148.             scrY;        /* Screen Y coordinate of screenBits */
  149.     CrState        state;      /* Current state of the cursor */
  150. } CrPrivRec, *CrPrivPtr;
  151.  
  152. /*
  153.  * Frame-buffer-private info.
  154.  *    fd            file opened to the frame buffer device.
  155.  *    info          description of the frame buffer -- type, height, depth,
  156.  *                  width, etc.
  157.  *    fb            pointer to the mapped image of the frame buffer. Used
  158.  *                  by the driving routines for the specific frame buffer
  159.  *                  type.
  160.  *    mapped          flag set true by the driver when the frame buffer has
  161.  *                  been mapped in.
  162.  *    parent          set true if the frame buffer is actually a SunWindows
  163.  *                  window.
  164.  *    fbPriv          Data private to the frame buffer type.
  165.  */
  166. typedef struct {
  167.     pointer           fb;         /* Frame buffer itself */
  168.     Bool              mapped;        /* TRUE if frame buffer already mapped */
  169.     Bool        parent;        /* TRUE if fd is a SunWindows window */
  170.     fbtype         info;        /* Frame buffer characteristics */
  171.     void        (*EnterLeave)();    /* screen switch */
  172.     pointer           fbPriv;        /* Frame-buffer-dependent data */
  173.     int            fd;        /* fd of frame buffer */
  174. } fbFd;
  175.  
  176. extern Bool sunSupportsDepth8;
  177. extern unsigned long sunGeneration;
  178.  
  179. typedef struct _sunFbDataRec {
  180.     Bool    (*probeProc)();    /* probe procedure for this fb */
  181.     char    *devName;        /* device filename */
  182.     Bool    (*createProc)();    /* create procedure for this fb */
  183. } sunFbDataRec;
  184.  
  185. extern sunFbDataRec sunFbData[];
  186. /*
  187.  * Cursor functions
  188.  */
  189. extern void       sunInitCursor();
  190. #ifdef SUN_WINDOWS
  191. extern Bool      sunSetCursorPosition();
  192. extern Bool      (*realSetCursorPosition)();
  193. #endif
  194.  
  195. /*
  196.  * Initialization
  197.  */
  198. extern Bool       sunScreenInit();
  199. extern int        sunOpenFrameBuffer();
  200.  
  201. extern fbFd       sunFbs[];
  202.  
  203. extern int        lastEventTime;    /* Time (in ms.) of last event */
  204. extern void       SetTimeSinceLastInputEvent();
  205.  
  206. extern int monitorResolution;
  207.  
  208. #define AUTOREPEAT_INITIATE    (200)        /* milliseconds */
  209. #define AUTOREPEAT_DELAY    (50)        /* milliseconds */
  210. /*
  211.  * We signal autorepeat events with the unique Firm_event
  212.  * id AUTOREPEAT_EVENTID.
  213.  * Because inputevent ie_code is set to Firm_event ids in
  214.  * sunKbdProcessEventSunWin, and ie_code is short whereas
  215.  * Firm_event id is u_short, we use 0x7fff.
  216.  */
  217. #define AUTOREPEAT_EVENTID      (0x7fff)        /* AutoRepeat Firm_event id */
  218.  
  219. extern int    autoRepeatKeyDown;        /* TRUE if key down */
  220. extern int    autoRepeatReady;        /* TRUE if time out */
  221. extern int    autoRepeatDebug;        /* TRUE if debugging */
  222. extern long    autoRepeatInitiate;
  223. extern long     autoRepeatDelay;
  224. extern struct timeval autoRepeatLastKeyDownTv;
  225. extern struct timeval autoRepeatDeltaTv;
  226.  
  227. #define tvminus(tv, tv1, tv2)    /* tv = tv1 - tv2 */ \
  228.         if ((tv1).tv_usec < (tv2).tv_usec) { \
  229.             (tv1).tv_usec += 1000000; \
  230.             (tv1).tv_sec -= 1; \
  231.         } \
  232.         (tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \
  233.         (tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec;
  234.  
  235. #define tvplus(tv, tv1, tv2)    /* tv = tv1 + tv2 */ \
  236.         (tv).tv_sec = (tv1).tv_sec + (tv2).tv_sec; \
  237.         (tv).tv_usec = (tv1).tv_usec + (tv2).tv_usec; \
  238.         if ((tv).tv_usec > 1000000) { \
  239.             (tv).tv_usec -= 1000000; \
  240.             (tv).tv_sec += 1; \
  241.         }
  242.  
  243. /*-
  244.  * TVTOMILLI(tv)
  245.  *    Given a struct timeval, convert its time into milliseconds...
  246.  */
  247. #define TVTOMILLI(tv)    (((tv).tv_usec/1000)+((tv).tv_sec*1000))
  248.  
  249. #ifdef SUN_WINDOWS
  250. extern int windowFd;
  251. #endif SUN_WINDOWS
  252.  
  253. #endif _SUN_H_
  254.